<include file="public@admin_head" />

<php>$submenus=$menus;</php>

<php>
    if (!function_exists('getsubmenu')) {
    function getsubmenu($submenus){

</php>
<notempty name="submenus">
    <php>foreach($submenus as $menu){</php>
    <li>
        <php>
            $menu_name=lang($menu['lang']);
            $menu_name=$menu['lang']==$menu_name?$menu['name']:$menu_name;
        </php>
        <php>if(empty($menu['items'])){</php>
        <a href="javascript:openapp('{$menu.url}','{$menu.id}','{$menu_name}',true);">
            <i class="fa fa-{$menu.icon|default='desktop'}"></i>
            <span class="menu-text"> {$menu_name} </span>
        </a>
        <php>}else{</php>
        <a href="javascript:openapp('{$menu.url}','{$menu.id}','{$menu_name}',true);" class="dropdown-toggle">
            <i class="fa fa-{$menu.icon|default='desktop'} normal"></i>
            <span class="menu-text normal"> {$menu_name} </span>
            <b class="arrow fa fa-angle-right normal"></b>
            <i class="fa fa-reply back"></i>
            <span class="menu-text back">返回</span>
        </a>

        <ul class="submenu">
            <php>getsubmenu1($menu['items'])</php>
        </ul>
        <php>}</php>

    </li>

    <php>}</php>
</notempty>
<php>
    }
    }
</php>

<php>
    if (!function_exists('getsubmenu1')) {
    function getsubmenu1($submenus){
</php>
<php>foreach($submenus as $menu){</php>
<li>
    <php>
        $menu_name=lang($menu['lang']);
        $menu_name=$menu['lang']==$menu_name?$menu['name']:$menu_name;
    </php>
    <php>if(empty($menu['items'])){</php>
    <a href="javascript:openapp('{$menu.url}','{$menu.id}','{$menu_name}',true);">
        <i class="fa fa-caret-right"></i>
        <span class="menu-text">
            {$menu_name}
        </span>
    </a>
    <php>}else{</php>
    <a href="javascript:openapp('{$menu.url}','{$menu.id}','{$menu_name}',true);" class="dropdown-toggle">
        <i class="fa fa-caret-right"></i>
        <span class="menu-text">
            {$menu_name}
        </span>
        <b class="arrow fa fa-angle-right"></b>
    </a>
    <ul class="submenu">
        <php>getsubmenu2($menu['items'])</php>
    </ul>
    <php>}</php>

</li>

<php>}</php>
<php>}
    }
</php>

<php>
    if (!function_exists('getsubmenu2')) {
    function getsubmenu2($submenus){
</php>
<php>foreach($submenus as $menu){</php>
<li>
    <php>
        $menu_name=lang($menu['lang']);
        $menu_name=$menu['lang']==$menu_name?$menu['name']:$menu_name;
    </php>

    <a href="javascript:openapp('{$menu.url}','{$menu.id}','{$menu_name}',true);">
        &nbsp;<i class="fa fa-angle-double-right"></i>
        <span class="menu-text">
            {$menu_name}
        </span>
    </a>
</li>

<php>}</php>
<php>}
    }
</php>
</head>
<body>
    <div class="wrap js-check-wrap">
        <ul class="nav nav-tabs">
            <li class="active"><a href="#A" data-toggle="tab">{:lang('MENU_LIST')}</a></li>
        </ul>
        <div class="alert alert-info mt-3" role="alert">获取所有菜单栏</div>

        <ul class="nav nav-list">
            {:getsubmenu($submenus)}
        </ul>
    </div>
    <script type="text/javascript" src="__STATIC__/js/admin.js?v={$_static_version}"></script>

    <script>
        function openapp(url, appId, appname, refresh) {
            window.parent.openapp(url, appId, appname, refresh);
        }
    </script>
</body>
</html>